home *** CD-ROM | disk | FTP | other *** search
/ Aminet 5 / Aminet 5 - March 1995.iso / Aminet / util / cli / Ver2Comm.lha / v2c_1.0.c < prev    next >
C/C++ Source or Header  |  1992-09-02  |  2KB  |  69 lines

  1. /* This little utility will turn a file version into its comment.
  2.  
  3.    Who needs this?
  4.      Someone who uses some kind of directory utility which displays file
  5.      comment but not version. You can select file, click v2c, rescan
  6.      the directory and just read the comment.
  7.  
  8.    Why is this useful?
  9.      Sometimes you get some kind of a short utility which you allready have
  10.      but filsizes dont match. Its a short way to find out which one is newer.
  11.  
  12.    How do I use it?
  13.      Usage is "v2c <Filename>" (no Wildcards permitted)
  14.  
  15.    Why no wild cards?
  16.      There is no need for that if your directory utility supports a single
  17.      call for every item you selected. If it doesn't, bad luck :)
  18.  
  19.    This code is crap!
  20.      It is my gift to you.
  21.  
  22.    This is just what I have been waiting for and I want to contact the
  23.    author and congratulate him!
  24.      Great! Glad that at least someone is happy. If you like this, use it
  25.      or want a better version, write to me and I'll be happy to help you. 
  26.  
  27.      My address is:
  28.  
  29.      Drago Fiser
  30.      Plecnikova 5
  31.      62000 Maribor
  32.      Slovenia, Europe
  33.      Tel. +386 (0)62 31956
  34.  
  35.      E-mail: Drago.Fiser@uni-mb.si
  36.  
  37. */
  38.  
  39. #include <proto/dos.h>
  40.  
  41. int GetVersion(BPTR fil,char *filcomm)
  42. { char d, *versionstring="$VER: v2c 1.00  22.11.1994 by Drago Fiser";
  43.   int i=0;
  44.   ULONG filelength, st;
  45.  
  46.   Seek(fil,0,OFFSET_END);
  47.   filelength=Seek(fil,0,OFFSET_BEGINNING);
  48.   for (st=0; st<filelength; st++) {
  49.    if ((d= FGetC(fil)) ==versionstring[i]) {
  50.     if ((++i)==5) { FGets(fil,filcomm,80); return(1); }
  51.    } else i=0;
  52.   }
  53.   return(0);
  54. }
  55.  
  56. main( int argc, char **argv)
  57. {
  58.  char filcomm[80];
  59.  BPTR Fil;
  60.  
  61.  if (argc==2) {
  62.   if (Fil=Open(argv[1],MODE_OLDFILE)) {
  63.     if (GetVersion(Fil,filcomm)) SetComment(argv[1],filcomm);
  64.     else SetComment(argv[1],".");
  65.    Close(Fil);
  66.   } else PutStr("File does not exist.\n");
  67.  } else PutStr("Wrong number of arguments.\n");
  68. }
  69.